numberX=size(Xtrain);
for i=1:numberX(1)
    x0 =zeros(3+3*2, 1);
    P0=eye(9);
    Xtest=Xtrain(i,:);
    %运行神经网络
    preY=NN(Xtest);
    %协方差参数
    q=0.01;
    r=0.01;
    Q=q*eye(9);
    R=r*eye(3);H1=zeros(3,3);
    %运行线性卡尔曼滤波
    %H矩阵
    for j=1:3
        H1(j,j)=preY(j);
    end
    H2=zeros(3,3*2);
    for j=1:3
        H2(j,(j*2-1):(j*2))=Xtest;
    end
    H=[H1,H2];
    %xs_
    xs_=x0;
    %P_
    P_=P0+Q;
    %K
    K=P_*H'*inv(H*P_*H'+R);
    %z
    z=[Ytrain(i,1);Ytrain(i,2);Ytrain(i,3)];
    %x_
    x_=xs_+K*(z-H*xs_);
    %P
    P=(eye(9)-K*H)*P_;
    %zOUT
    zOUT=H*x_;
    zOUT=round(zOUT);
end